package com.liang.file;

import java.io.File;

public class FileText3 {
    public static void main(String[] args) {
        File file = new File("D:\\itheima\\aaa");

        File[] files = file.listFiles();

        if(files !=null){
            for (File file1 : files) {
//                System.out.println(file1);
            }
        }
        File file1 = new File("D:\\itheima");
        method(file1);

    }

    public static void method(File file) {


        File[] files = file.listFiles();
        if (files != null) {
            for (File file1 : files) {
//                System.out.println(file1.list().length);
                if (file1.isFile()) {
                    file1.delete();
                }else{
//                    System.out.println(file.listFiles());
                    if (file1.listFiles().length == 0) {
                        file1.delete();
                    }else{
                        method(file1);
                    }
                }
            }
        }
    }
}
